Linux Command Line and Shell Scripting Bible by Richard Blum & Christine Bresnahan

Linux Command Line and Shell Scripting Bible by Richard Blum & Christine Bresnahan

Author:Richard Blum & Christine Bresnahan [Blum, Richard & Bresnahan, Christine]
Language: eng
Format: epub, azw3, mobi, pdf
Tags: Reference:Computers
ISBN: 9781118004425
Publisher: Wiley
Published: 2008-01-02T10:00:00+00:00


That's simple enough. On the trap command line, you just list the commands you want the shell to execute, along with a space-separated list of signals you want to trap. You can specify the signals either by their numeric value or by their Linux signal name.

Here's a simple example of using the trap command to ignore SIGINT and SIGTERM signals:

$

$ cat test1

#!/bin/bash

# testing signal trapping

#

trap “echo ‘ Sorry! I have trapped Ctrl-C’” SIGINT SIGTERM

echo This is a test program

count=1

while [ $count -le 10 ]

do

echo “Loop #$count”

sleep 5

count=$[ $count + 1 ]

done

echo This is the end of the test program

$



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.